Functional Object-Oriented Programming with Object-Gofer
نویسندگان
چکیده
Object-Gofer is a small, practical extension of the functional programming language Gofer incorporating the following ideas from the object-oriented community: objects and toplevel classes, subtype and implementation inheritance, method redefinition, late binding and self type specialization. The semantics of Object-Gofer is defined by translation into pure Gofer. Although this restricts the design space, it turns out that using a suitable framework of monads, higher-order polymorphism, and overloading, objects smooth well with functions. 1 Case for Functional Object-oriented Programming Object-oriented concepts are ubiquitous in programming. Objects may model real life entities, or may represent system artifacts like stacks. Objects provide a way to structure a system and to control the computation. The most characteristic feature of object-oriented programming is inheritance, which allows new classes to be defined as increments of existing ones. Inheritance comes with late binding, inclusion polymorphism (subtyping), method redefinition, and method specialization (cf. [3]). In a functional language, the programmer declares referential transparent functions: Whenever a function is called, it returns the same result for the same arguments. Thus, functional programming languages allow for elegant reasoning. Furthermore, functional languages support specification and programming at a rather high level using type inference, parametric polymorphism, higher-order functions, lazy evaluation, and algebraic datatypes (cf. [1]). Object-Gofer combines the expressiveness of object-oriented programming with the elegant reasoning principles of functional programming languages. We choose Gofer [8], a subset of Haskell [5], as the functional basis, because of its extended type system, which permits higher-order polymorphism and overloading [10], and because of its support of monads. Monads offer a general framework to deal with imperative concepts like I/O and state manipulation. Therefore, monads are the glue between the object-oriented and the functional features of Object-Gofer. For a detailed discussion of monads, we refer to [17]. Currently, a precompiler, called Fog, translates Object-Gofer into pure Gofer. This translation defines the semantics of Object-Gofer. With Fog, we have developed several non-trivial applications, for example, a graphical editor and a specification of the Unix file system. We refer the reader to a forthcoming technical report, where the principles of the implementation of Fog and convincing case studies are presented in detail. 2 Classes and Objects Object-Gofer is a class-based language. A class describes the structure and behaviour of all the objects generated from this class. As an example, we consider the class Cell (see below), which describes storage-cells. It has an integer attribute contents , the methods set and get , and the generator Cell . The attributes and methods of a class are collectively called its features. object class Cell where
منابع مشابه
Declarative Semantics in Object-Oriented Software Development - A Taxonomy and Survey
One of the modern paradigms to develop an application is object oriented analysis and design. In this paradigm, there are several objects and each object plays some specific roles in applications. In an application, we must distinguish between procedural semantics and declarative semantics for their implementation in a specific programming language. For the procedural semantics, we can write a ...
متن کاملModeling and Evaluation of Stochastic Discrete-Event Systems with RayLang Formalism
In recent years, formal methods have been used as an important tool for performance evaluation and verification of a wide range of systems. In the view points of engineers and practitioners, however, there are still some major difficulties in using formal methods. In this paper, we introduce a new formal modeling language to fill the gaps between object-oriented programming languages (OOPLs) us...
متن کاملModeling and Evaluation of Stochastic Discrete-Event Systems with RayLang Formalism
In recent years, formal methods have been used as an important tool for performance evaluation and verification of a wide range of systems. In the view points of engineers and practitioners, however, there are still some major difficulties in using formal methods. In this paper, we introduce a new formal modeling language to fill the gaps between object-oriented programming languages (OOPLs) us...
متن کاملModelsaz: An Object-Oriented Computer-Aided Modeling Environment
Modeling and simulation of processing plants are widely used in industry. Construction of a mathematical model for a plant is a time-consuming and error-prone task. In light of extensive advancements in computer science (both hardware and software), computers are becoming a necessary instrument in industrial activities. Many software tools for modeling, simulation and optimization of proces...
متن کاملObjects Identification in Object-Oriented Software Development - A Taxonomy and Survey on Techniques
Analysis and design of object oriented is onemodern paradigms for developing a system. In this paradigm, there are several objects and each object plays some specific roles. Identifying objects (and classes) is one of the most important steps in the object-oriented paradigm. This paper makes a literature review over techniques to identify objects and then presents six taxonomies for them. The f...
متن کامل